package string;

import java.util.Scanner;

/**
 * 字符串的左旋转操作是把字符串前面的若干个字符转移到字符串的尾部。
 * 请定义一个函数实现字符串左旋转操作的功能。
 * 比如，输入字符串"abcdefg"和数字2，该函数将返回左旋转两位得到的结果"cdefgab"。
 * bacdefg
 * gfedcab
 * cdefgab
 */
public class ReverseLeftWords {
    public static void main(String[] args) {
        ReverseLeftWords re = new ReverseLeftWords();
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            String s = scanner.next();
            String s1 = re.reverseLeftWords(s, n);
            System.out.println(s1);
        }
    }
    public String reverseLeftWords(String s, int n) {
        char[] c = s.toCharArray();
        reverse(c,0,n - 1);
        reverse(c,n,c.length - 1);
        reverse(c,0,c.length - 1);
        return String.valueOf(c);
    }
    public void reverse(char[] s,int left,int right){
        int count = (right - left) / 2;
        for (int i = 0; i <= count; i++) {
            char swap = s[left];
            s[left] = s[right];
            s[right] = swap;
            right--;
            left++;
        }
    }
}
